package com.badu.common.utils;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Random;
import java.util.UUID;

/**
 * @author bootdo
 */
public class StringUtils extends org.apache.commons.lang3.StringUtils {

	// 生产订单号
	public static String generateOrderSn() {
		DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyyMMdd");
		String now = df.format(LocalDate.now());
		String orderSn = "o"+now + getRandomNum(6);
		return orderSn;
	}
	
	// 生产订单号
	public static String generateRegisterCodeSn() {
		String registerCode = "rg" + getRandomNum(6);
		return registerCode;
	}

	// 生产随机数
	private static String getRandomNum(Integer num) {
		String base = "0123456789";
		Random random = new Random();
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < num; i++) {
			int number = random.nextInt(base.length());
			sb.append(base.charAt(number));
		}
		return sb.toString();
	}

	// 随机产生boolean值
	public static Boolean generateBoolean() {
		int sj = (int) (Math.random() * 10);
		if (sj > 5) {
			return true;
		} else {
			return false;
		}
	}
	
	public static void main(String[] args) {
		System.out.println(generateOrderSn());
	}
}
